# 构建阶段
FROM golang:1.17-alpine AS build

#启用go module
ENV GO111MODULE=on \
    GOPROXY=https://goproxy.cn,direct
WORKDIR /app
COPY . .

# 指定OS等，并go build
RUN GOOS=linux GOARCH=amd64 go build .

RUN mkdir publish && cp webserver publish


# 运行阶段
FROM alpine
WORKDIR /app
# 将上一阶段的构建的文件赋值过来
COPY --from=build /app/publish .
ENTRYPOINT ["./webserver"]

# 镜像已推送至intelycc/webserver